package com.medvalley.tcm.controller;

import com.medvalley.tcm.base.Result;
import com.medvalley.tcm.domain.Feedback;
import com.medvalley.tcm.service.impl.FeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Api(value = "意见反馈")
public class FeedbackController extends BaseController {

    @Autowired
    private FeedbackService feedbackService;

    @ApiOperation(value = "意见反馈")
    @RequestMapping("/feedback")
    public Result feedback(@RequestParam String advice, @RequestParam String token, HttpServletRequest request) {
        Feedback feedback = new Feedback();
        feedback.setContent(advice);
        feedback.setPhone(getSessionPhone(request));
        feedbackService.addFeedback(feedback);
        return success("已经收到您的反馈，谢谢！");
    }

}
